//
//  ViewController.m
//  ZSHUDManager
//
//  Created by 字节科技 on 2018/12/20.
//  Copyright © 2018 Byte. All rights reserved.
//

#import "ViewController.h"
#import "ZSHUDManager.h"
#import "RunLabel.h"
#import "TestViewController.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableV;

@end

@implementation ViewController
static NSString *ident = @"kkdjksnkjsdbdksbjvh";
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"HUD";
    self.tableV.tableFooterView = [[UIView alloc]init];
    
    NSArray *numArr = @[@3,@1,@8,@4,@19,@200,@189,@19,@2];
    NSArray *sortArr = [numArr sortedArrayUsingFunction:inSort context:NULL];
    NSLog(@"%@",sortArr);
    
   
    
}
NSInteger inSort (id num1, id num2, void *context){
    int v1 = [num1 intValue];
    int v2 = [num2 intValue];
    
    if (v1 < v2) {
        
        return NSOrderedAscending;
        
    } else if (v1 > v2) {
        
        return NSOrderedDescending;
        
    } else {
        
        return NSOrderedSame;
    }
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 6;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ident];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ident];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    switch (indexPath.row) {
        case 0:
            cell.textLabel.text = @"信息提示";
            break;
        case 1:
            cell.textLabel.text = @"加载";
            break;
        case 2:
            cell.textLabel.text = @"进度条";
            break;
        case 3:
            cell.textLabel.text = @"提示成功";
            break;
        case 4:
            cell.textLabel.text = @"提示失败";
            break;
            
        default:
            cell.textLabel.text = @"跑马灯";
            break;
    }
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    switch (indexPath.row) {
            case 0:
            [ZSHUDManager showAutoHiddenToastWithMessage:@"这是一条提示!"];
            break;
        case 1:{
            [ZSHUDManager showLoading:@"加载中"];
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [ZSHUDManager hideLoading];
            });
            break;
        }
        case 2:{
         
            ZSUploadingView *uploadV = [ZSUploadingView showUploading:@"上传中"];
            __weak typeof(&*uploadV) weakV = uploadV;
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                weakV.floatProgress = 0.5;
            });
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                weakV.floatProgress = 1;
            });
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [weakV hideUploading];
            });
            break;
        }
            
        case 3:
            
            [ZSHUDManager showSuccess:@"了金合欢花或或或或成功咔咔咔咔咔咔扩扩扩扩扩咔咔咔咔咔咔扩扩扩咔咔咔咔咔咔扩扩"];
            break;
            
        case 4:
            [ZSHUDManager showError:@"失败顶顶顶顶都是对的多多"];
            break;
        default:{
            TestViewController *testVC = [[TestViewController alloc]initWithNibName:@"TestViewController" bundle:nil];
            [self.navigationController pushViewController:testVC animated:YES];
            break;
        }
    }

    
}
@end
